package utils;

import java.io.File;
import java.io.IOException;
import java.util.Iterator;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.handlers.HandlerUtil;

import views.SelectedView;
import views.ShowsView;
import data.ShowData;

public class RenameHandler extends AbstractHandler
{
    @Override
    public Object execute(ExecutionEvent event) throws ExecutionException
    {
        StructuredSelection sels = (StructuredSelection) SelectedView
                .getInstance().getSelection();
        for (Iterator iterator = sels.iterator(); iterator.hasNext();)
        {
            ShowData data = (ShowData) iterator.next();
            ShowData newShowData = SageTvShows.getInstance().renameFileNameInShow(data.getShowId());
            SelectedView.getInstance().refreshShow(data, newShowData);
            ShowsView.getInstance().refreshShow(data, newShowData);
        }
        return null;
    }
    

}
